package com.meis.base.mei.utils

/**
 * 用于视频点赞数量，评论数量，分享数量等数量工具类
 * For the brave souls who get this far: You are the chosen ones,
 * the valiant knights of programming who toil away, without rest,
 * fixing our most awful code. To you, true saviors, kings of men,
 * I say this: never gonna give you up, never gonna let you down,
 * never gonna run around and desert you. Never gonna make you cry,
 * never gonna say goodbye. Never gonna tell a lie and hurt you.
 */
object NumberUtils {

    private const val THOUSAND = 10000;

    /**
     * 性能考虑,直接字符串截取
     */
    fun convertOneDecimalW(count: Int): String {
        if (count < THOUSAND) return count.toString();
        var result = (count.toFloat() / THOUSAND).toString();
        val end = result.indexOf(".") + 2;
        if (end <= result.length) {
            return result.substring(0, end) + "w";
        }
        return "${result}w";
    }

}